/*
 *暑期JAVA学习 版权所有 2022-2025 
 */
package com.ychs.corejava.day05;

import java.time.Month;

import com.ychs.corejava.lesson4.LeapYear;

/**
 *任务：给定年和月，输出这个月的天数
 * @author  menlu
 * @version 1.0
 */
public class OutPutDay {

	/**
	 * 根据年和月得到当月的天数
	 * @param year 年份 
	 *  @param month 月份
	 * @return 天数
	 */
	public int getDays(int year,int month) {
		int days=30;
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			days = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			days = 30;
			break;
		case 2:
			LeapYear leapYear = new LeapYear();
			boolean flag = leapYear.LeapYear(year);
			if (flag) {
				days = 29;
			}else {
				days=28;
			}
		}
		return days;
	}
}

